<?php
$access_level = 0;
$page_title = 'eTAT';
require_once 'controller.php';
//handle post events.
if(isset($_POST['login_submit'])) {
	$email = $_POST['email'];
	$password = makePassword($_POST['password']);
	$query = mysql_query("SELECT * FROM `instructor` WHERE `email`='$email' AND `password`='$password' AND `permission` = '2'") or die(mysql_error());
	$result = mysql_fetch_object($query);
	if($result) {
		$_SESSION['logged_in'] = $result->id;
		unset($_SESSION['m']);
		$_SESSION['user'] = $result;
		redirect("myetat.php");
	} else {
		$_SESSION['m'] = 2;
		redirect("index.php");
	}
}
if(isset($_POST['forgot_pass_submit'])) {
	$email = $_POST['email'];
	$query = mysql_query("SELECT * FROM `instructor` WHERE `email`='$email'") or die(mysql_error());
	$result = mysql_fetch_object($query);
	if($result) {
		//@TODO: reset password and send email
		redirect('index.php?m=4');
	} else {
		redirect('index.php?m=6');
	}
}
if (isset($_POST['logout_submit'])) {
	logout();
}
require_once 'header.php';
?>
<!-- left bar open -->
<div id="index-left">
	<h1>Welcome to eTAT!</h1>
	<p>The eTAT (Electronic Teamwork Assessment Tool) is a web based
	application tool that plans to provide assessment and measures of
	teamwork with the help of all the data obtained from various sources
	such as hosting platforms and surveys, process this data. e-TAT
	integrates, stores and presents the three key complementary components</p>
	<ul>
		<li>Participants' usage of communication and SE development tools</li>
		<li>Surveys</li>
		<li>instructors' annotations and observations</li>
	</ul>
	<div class="right"><a href="">More...</a></div>
</div>
<!-- left bar close -->
<!-- right bar open -->
<div id="index-right">
	<h2>To Start Please Login:</h2>
	<?php
		$form1 = new Form('user_login_form','post',true);
		$form1->textInput('email','Gmail Address&nbsp;&nbsp;');
		$form1->textInput('password','Password&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',array('type'=>'password'));
		$form1->button('login_cancel','Cancel',array('type'=>'button','onclick'=>'close_popup();'),false);
		$form1->button('login_submit','Login',array('type'=>'submit'),false);
		//$form1->button('forgot_pass','Forgot Username/Password',array('type'=>'button','onclick'=>'javascript:forgotPass();'));
		$form1->anchorButton('forgot_pass','<br>Forgot Password?&nbsp;&nbsp;', 'javascript:void(0);', array('onclick'=>'javascript:forgotPass();'));
		$form1->anchorButton('new_users','<br>New User? Register Here', 'javascript:void(0);', array('onclick'=>'javascript:window.location="register.php"'));
		//print newBtn('new_users','New Users',array('type'=>'button','onclick'=>'javascript:window.location="register.php"'));
		$form1->text("<div class='clear'></div>");
		$form2 = new Form('forgot_pass_form','post',true,array('class'=>'invisible'));
		$form2->textInput('email','Gmail Address');
		$form2->button('forgot_pass_submit','Reset Password',array('type'=>'submit'),false);
		$form2->button('cancel_pass','Cancel',array('type'=>'button','onclick'=>'javascript:cancelForgotPass();'),false);
		$form2->text("<div class='clear'></div>");
		print popupDisplay('login-box',$form1->build().$form2->build(),250,array('top'=>200,'right'=>10));
		print newBtn('admin_access','Administrator Console',array('type'=>'button','onclick'=>'javascript:window.location="admin.php"'));
	?>
</div>
<!-- right bar close -->
<!-- main content part open -->
<div id="mainIndex">
	<h1>How To Use!</h1>
	<ul>
		<li>Students use Google code and Google groups for software development
		and collaboration</li>
		<li>Student groups registers and create their own group site</li>
		<li>instructors' launches etat via a web browser and creates his/her
		courses</li>
		<li>Links to student groups in via urls of the groups created in group
		services</li>
		<li>Instructor creates assessment Surveys and sets up a mailing list
		and survey delivery schedule</li>
	</ul>
	<div class="right"><a href="">More...</a></div>
</div>
<!-- main content part close -->
<?php require_once 'footer.php'; ?>




